<?php
/**
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT		: Rubik Ultimate Framework
 * @version 	: 1.1
 * COPYRIGHT    : 2008
 * ------------------------------------------------------
 * 
 * Created on	:  Jul 7, 2008
 * 
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );

RCoreImporter::cls('plugin.PluginManager');
/**
 * Trigger the plugin of a group.
 *
 * @param string $pluginGroup
 * @param string $runtimeParams
 * @return null
 */
function &triggerPlugins($pluginGroup, &$runtimeParams = null) {
	$plugin = new PluginManager($pluginGroup);
	$plugin->runPlugins($runtimeParams);
	return $runtimeParams;
}

// Call Ext process before init System
//RExtImporter::sysProcessFile ( "beforeInitSys.php" );
triggerPlugins( "beforeInitSys" );

// 3.	Sau đó index.php sẽ gọi file initSystem.php để khởi tạo các thông số của hệ thống.
RCoreImporter::sysProcessFile ( "initSystem.php" );

// Call Ext process after init System
//RExtImporter::sysProcessFile ( "afterInitSys.php" );
triggerPlugins( "afterInitSys" );

// 4.	Sau khi các thông tin về hệ thống đã được khởi tạo, 
//	application sẽ được khởi tạo thông qua: runApplication.php

// If we using ajax -> the return value will be print imediatlly
if (SysRequest::isAjax () === false) {
	// In case of without ajax, we will save all content into SystemSite::appContent
	ob_start ();
}

// Call Ext process before run application
//RExtImporter::sysProcessFile ( "beforeRunApp.php" );
triggerPlugins("beforeRunApp");

RCoreImporter::sysProcessFile ( "runApplication.php" );

// Call Ext process before run application
//RExtImporter::sysProcessFile ( "afterRunApp.php" );
triggerPlugins("afterRunApp");

if (SysRequest::isAjax () === false) {
	// In case of without ajax, we will save all content into SystemSite::appContent
	SysResponse::setAppContent ( ob_get_contents () );
	ob_end_clean ();
} else {
	// We do nothing when this is an ajax request
	exit ( 0 );
}

SysTemplate::runSiteTemplate ();
SysResponse::echoAllHtml ();

// Call Ext process after init System
//RExtImporter::sysProcessFile ( "afterRenderIndex.php" );
triggerPlugins("afterRenderIndex");
?>